package com.tjbklx1.thread.chap01.practice05;

public class SecurityGate {

	private int  counter = 0;

	public void enter() { //synchronized
		int currentCounter = counter;
		Thread.yield();	// 测试程序的不安全性
		counter = counter + 1;
	}

	public void exit() {	//synchronized
		int currentCounter = counter;
		Thread.yield();
		counter = counter - 1;
	}

	public int getCounter() {
		return counter;
	}
}
